A=c(1:10)
B=c("a","b","c","a","b","c","a","b","c","a")
tapply(A, B, mean)
C=seq(1,20,2)
D=rep(2,times=10)
E=data.frame(A,B,C,D)
print(E)
#读取并合并文件
file1=read.table("D:/浏览器下载/data for class3/ADdata1.txt")
print(file1)
file2=read.csv("D:/浏览器下载/data for class3/ADdata2.csv")
print(file2)
library("openxlsx")#已经通过工具栏下载了相应R包，这里直接调用
file3=read.xlsx("D:/浏览器下载/data for class3/ADdata3.xlsx")
print(file3)
file4=read.table("D:/浏览器下载/data for class3/ADdata4.txt")
print(file4)

df1=merge(file1,file2,by.x = "row.names",by.y="X")#合并file1和file2
print(df1)

df2=merge(file3,file4,by.x = "X1",by.y="row.names")#合并file3和file4
print(df2)
df3=merge(df1,df2,by.x = "Row.names",by.y="X1")#合并df1和df2
print(df3)
#写入文件
write.table(df3,file = "D:/浏览器下载/data for class3/newfile1.txt")
write.csv(df3,file = "D:/浏览器下载/data for class3/newfile2.csv")
write.xlsx(df3,file = "D:/浏览器下载/data for class3/newfile3.xlsx")


# file1=read.table("D:/浏览器下载/data for class3/ADdata1.txt")
# View(file1)
# file2=read.csv("D:/浏览器下载/data for class3/ADdata2.csv")
# View(file2)
# library("openxlsx")
# file3=read.xlsx("D:/浏览器下载/data for class3/ADdata3.xlsx")
# View(file3)
# file4=read.table("D:/浏览器下载/data for class3/ADdata4.txt")
# View(file4)